<?php
namespace Api\Controller;
use Think\Controller;

/**
 *
 */
class ApiBaseController extends Controller
{
    protected $data;
    function _initialize(){

        header("Access-Control-Allow-Origin: *");
        $this->data = json_decode(file_get_contents('php://input'));
        if(!$this->data){
            $this->data = $_REQUEST;
        }

    }

    protected function ApiReturn($code = 0,$msg= "成功",$data=array()){

        $jsonData = array(
            'code' => $code,
            'msg'  => $msg,
            'data' => $data,
            'time'=>time()
        );

        echo json_encode($jsonData);
        exit();
    }
}

?>